@echo off

REM step 1. Install required packages using vcpkg
vcpkg.exe install devil openjpeg libiconv zlib freetype cairo pthreads pkg-config
set "PATH=%PATH%;C:\vcpkg\downloads\tools\msys2\21caed2f81ec917b\mingw64\bin"
REM step 2. Check if pkg-config is available
pkg-config.exe --version


echo pkg-config found successfully. Continuing with build...


REM step 3. Delete existing build directory if it exists
if exist build rmdir /s /q build


REM Create new build directory
mkdir build

REM Navigate to build directory
cd build

REM step 4. Configure with CMake
cmake -G "Visual Studio 17 2022" -A x64 ^
  -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
  -DQt5_DIR="C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/lib/cmake/Qt5" ^
  -DCMAKE_CXX_STANDARD=14 ^
  -DCMAKE_BUILD_TYPE=Release ^
  -T "v140" ^
  -DCMAKE_SYSTEM_VERSION="10.0.240.0" ^
  ..


@REM cmake -G "Visual Studio 17 2022" -A x64 ^
@REM   -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
@REM   -DQt5_DIR="C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/lib/cmake/Qt5" ^
@REM   -DCMAKE_CXX_STANDARD=14 ^
@REM   -DCMAKE_BUILD_TYPE=Release ..


REM step 5. Build the project
cmake --build . --config Release

REM Return to parent directory
cd ..